@extends('develop.layoutEdit')

@section('title')
    <li class="cur">
        <span>支付宝服务窗设置</span>
    </li>
@endsection


@section('css')
    <style>
        .layer-go-back{
            display:none;
        }
    </style>
@endsection

@section('content')

<div class="form-group">
    <label class="col-sm-3 control-label" for="app_id"><span class="red pr5">*</span>公众账号ID：</label>
    <div class="col-sm-5">
        <input id="app_id" class="form-control" type="text" placeholder="公众账号ID" name="app_id" value="{{ $configure['app_id'] }}">
    </div>
</div>
<div class="form-group">
    <label class="col-sm-3 control-label"></label>
    <div class="col-sm-9">
        <input type="hidden" name="function_id" id="function_id" value="{{ $function_id or ''}}">
        <input type="button"  value="保存" onclick="func.edit();" class="btn btn-success" >
    </div>
</div>

@endsection
@section('js')
    <script>

        var func = {

            //保存
            edit:function(){

                var message_log = '' ;
                var configure = E.getFormValues('edit-form') ;

                //参数判断
                if( E.isEmpty( configure.function_id ) || !E.isInt( configure.function_id ) ) {
                    message_log += '参数错误<br/>' ;
                }
                if( E.isEmpty( configure.app_id ) || !E.isInt( configure.function_id ) ) {
                    message_log += '公众账号ID不能为空<br/>' ;
                }

                if( message_log ) {
                    layer.alert( message_log , { icon:2 });
                    return false ;
                }

                layer.confirm("您确认保存该设置吗？",{icon:3,offset:'50px'}, function ( index ){
                    layer.close( index );
                    E.ajax( {
                        type:'get',
                        url: '/lar/develop/function/store/'+function_id,
                        data: configure,
                        dataType:'json',
                        // 返回值判断
                        success: function ( obj ){

                            if ( obj.code == 200 ) {
                                layer.alert( obj.message , { icon: 1,time : 1500 } ) ;
                            } else {
                                layer.alert( obj.message , { icon: 2 } ) ;
                            }
                        }
                    } ) ;
                });
            }
        };
    </script>
@endsection